﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Bookkeeping.Core.Entities;
using Bookkeeping.Core.Services;
using Bookkeeping.Mvc.Models.Rendering;
using Bookkeeping.Mvc.Extensions;

namespace Bookkeeping.Mvc.Models.Budget
{
    public class PostViewModel
    {
        public PostViewModel(Post post)
        {
            Name = post.Name;
            Comment = post.Comment;
            Amount = post.Amount;
            Tags = post.Tags.ToSpaceSeparatedString();
            Id = post.Id;
            Year = post.DateTime.Year;
            Month = post.DateTime.Month;
        }

        public string Name { get; private set; }
        public string Comment { get; private set; }
        public double Amount { get; private set; }
        public string Tags { get; private set; }
        public int Id { get; private set; }
        public bool IsSelected { get; set; }
        public int Year { get; private set; }
        public int Month { get; private set; }

        public string AmountString
        {
            get
            {
                return Formatter.FormatMonetaryAmount(Amount);
            }
        }

        public string AmountCssClass
        {
            get
            {
                return Css.GetAmountClass(Amount);
            }
        }

        public string RowCssClass
        {
            get
            {
                if (IsSelected)
                    return "selected";

                return "";
            }
        }
    }
}
